package top.kaoshanji.r3ch11c;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

/**
 * @author kaoshanji
 * ^_^
 * create time 2025/5/9 14:30
 */
@Repository
public class PostDao {

    private JdbcTemplate jdbcTemplate;

    @Autowired
    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }

    public void addPost(final Post post) {
        String sql = " INSERT INTO t_post(topic_id,post_text) VALUES(?,?) ";
        Object[] params = new Object[]{post.getTopicId(),post.getPostText()};
        jdbcTemplate.update(sql, params);
    }

}
